<?php
require_once "genie_pdo.php";

$dbh = genie_connect();
	
$stmt = "SELECT artist, count(*) AS 'total' "
	  . "FROM songs "
	  . "GROUP BY artist "
	  . "ORDER BY count(*) DESC";

$sth = $dbh->query($stmt);

$return = "<Artists>";
while ($row = $sth->fetch (PDO::FETCH_OBJ))
{
	$return .= "<Artist><Name>".$row->artist."</Name><Total>".$row->total."</Total></Artist>";
}
$return .= "</Artists>";
	
print ($return);
	
$dbh = NULL;  # close connection

?>
